package com.fanfanwang.ffw.app.ui.my;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.toolbox.NetworkImageView;
import com.fanfanwang.ffw.app.AppManager;
import com.fanfanwang.ffw.app.asynctask.AddParknumAsyncTask;
import com.fanfanwang.ffw.app.base.BaseActivity;
import com.fanfanwang.ffw.app.bean.CarportBean;
import com.fanfanwang.ffw.app.common.StringUtils;
import com.fanfanwang.ffw.app.common.ToastAlone;
import com.fanfanwang.ffw.app.tenant.R;
import com.fanfanwang.ffw.app.tools.SharedPreferencesUtil;
import com.fanfanwang.ffw.app.ui.HomeActivity;
import com.fanfanwang.ffw.app.widget.CommonTitleBar;

/** 管理员 增加停车位的界面 */
public class GlyMyAddCarportAct extends BaseActivity {

	private CommonTitleBar commonTitleBar;
	private Activity mAct;
	private Intent mIntent;
	private EditText et_carport_num;
	private Button add_btn;

	public static IAddParknumable iAddParknumable;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		initView();
		AppManager.getAppManager().addActivity(this);
		initData();
		setListener();
	}

	@Override
	public void initView() {
		setContentView(R.layout.gly_activity_my_add_carport);
		mAct = this;
		commonTitleBar = (CommonTitleBar) findViewById(R.id.common_titlebar);
		et_carport_num=(EditText)findViewById(R.id.et_carport_num);
		add_btn=(Button)findViewById(R.id.add_btn);
	}

	@Override
	public void setListener() {
		commonTitleBar.setToolBarReturnOnclickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		add_btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String parknum=et_carport_num.getText().toString();
				if(TextUtils.isEmpty(parknum))
				{
					ToastAlone.showToast(mAct, getString(R.string.toast_check_carport));
				}else{

					new AddParknumAsyncTask(mAct, SharedPreferencesUtil.getInstance(mAct).getParkingId(), parknum).execute("");
				}
			}
		});

	}

	@Override
	public void initData() {
		// TODO Auto-generated method stub
		commonTitleBar.setCenterText(getString(R.string.add_carport));
		commonTitleBar.setReturnVisible();
		setInterface();
	}
	public void setInterface(){
		iAddParknumable=new IAddParknumable() {
			
			@Override
			public void addParknumSuccess() {
				// TODO Auto-generated method stub
				finish();
//				CarportBean carportBean=new CarportBean();
//				carportBean.carport_num=temp;
//				GlyMyCarportManagementAct.iAddCarportable.addCarport(carportBean);
//				ToastAlone.showToast(getApplicationContext(), getString(R.string.toast_add_success));
//				finish();
			}
		};
	}
	public interface IAddParknumable{
		public void addParknumSuccess();
	}
}
